<template>
  <!-- 规则历史页面 -->
  <div style="margin-bottom:20px;">
        <el-table ref="multipleTable" :data="tableData" width="calc(100% - 10px)">
          <el-table-column
            prop="methodRuleCode"
            label="规则编号"
            :show-overflow-tooltip="true"
          ></el-table-column>
            <el-table-column
            width="50"
            prop="versionNum"
            label="版本号"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column v-for="(value ,key) in this.headData"
            :key="key"
            :prop="key"
            :label="value"
            :show-overflow-tooltip="true"
          >
          <template>
            </template></el-table-column>
          <el-table-column
            prop="effectDate"
            :show-overflow-tooltip="true"
            label="生效日期"
            sortable
            width="120"
          >
            <template slot-scope="scope">
              <div v-if="scope.row.effectDate">
                {{ timeFormatShort(scope.row.effectDate) }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="invalidDate"
            :show-overflow-tooltip="true"
            label="生效截止日"
            sortable
          >
            <template slot-scope="scope">
              <div v-if="scope.row.invalidDate">
                {{ timeFormatShort(scope.row.invalidDate) }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="creator"
            label="创建人"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="createdTm"
            :show-overflow-tooltip="true"
            label="创建时间"
            sortable
          >
            <template slot-scope="scope">
              <div v-if="scope.row.createdTm">
                {{ timeFormat(scope.row.createdTm) }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
          <el-table-column
            prop="modifier"
            :show-overflow-tooltip="true"
            label="修改人"
            sortable
            :formatter="row => row.modifier || '-'"
          >
          </el-table-column>
          <el-table-column
            prop="modifiedTm"
            :show-overflow-tooltip="true"
            label="修改时间"
            sortable
          >
            <template slot-scope="scope">
              <div v-if="scope.row.createdTm">
                {{ timeFormat(scope.row.modifiedTm) }}
              </div>
              <div v-else>-</div>
            </template>
          </el-table-column>
        </el-table>
         <pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-size="size"
          @refresh="searchFunc"
          :total="total"
        ></pagination>
  </div>
</template>

<script>
import moment from "moment";
import { getDict } from "@/api/getDict";
export default {
  data() {
    return {
        page: 1,
        size: 15,
    };
  },
 props: ["headData","tableData","total"],
  components: {
    
  },
  created() {
    this.getDict();
  },
  mounted() {
  },
  
  methods: {
      handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
     this.$emit("handleSizeChange", val)
    },
    //当前页改变
    handleCurrentChange(val) {
      this.$emit("handleCurrentChange", val)
    },
    searchFunc(){
      this.$emit("searchFunc")
    },
      //列表动态数据赋值
    getDynamicValue(row, column) {
      let columnId = column.property;
      let data = row.ruleDatas;
      if (data.length > 0) {
        for (let i = 0;i < data.length;i++) {
          if(data[i].templateFieldId == columnId) {
            return data[i].ruleValue;
          }
        }
      }
    },
     timeFormat(val) {
      if (val) return moment(val).format("YYYY-MM-DD HH:mm:ss");
      else return "";
    },
    timeFormatShort(val) {
      if (val) return moment(val).format("YYYY-MM-DD");
      else return "";
    },


    
    getDict() {
      getDict("ccyManage_flag").then(res => {
        console.log(res, "字典启用");
        if (res.code == 200) {
          this.mgrRoleIdList = res.datas;
        }
      });
    },
   
  
  }
};
</script>

<style lang="scss" scoped>

</style>